<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="btn">刘德华</button>
    <div>123</div>
    <script>
        //点击按钮弹出对话框
        var btn = document.getElementById("btn");
        var div = document.querySelector("div");
        //事件类型 什么事件 比如鼠标点击 鼠标经过
        //事件处理程序 函数 通过函数赋值来实现
        btn.onclick = function() {
            alert("你好");
        }
        div.onclick = function() {
            console.log("ni");
        }
    </script>
</body>

</html>